/*

*** This do file creates the replication results for 

Why Aid is Unpredictable? An Empirical Analysis of the Gap Between Actual and Planned Aid (with Gustavo Javier Canavire-Bacarreza and Peter Nunnenkamp), Journal of International Development, 27 (4), 2015, pp. 440-463

Eric Neumayer (LSE)																			

Please report any errors to e.neumayer@lse.ac.uk

*/

use "Article for ID (aid) stacked.dta", replace
tsset country_id_devl_period acty


capture dropvars report_dum_*
gen report_dum_2008=0
replace report_dum_2008=1 if (acty==2008 & devl_period==1) | (acty==2009 & devl_period==2) | (acty==2010 & devl_period==3) 
gen report_dum_2009=0
replace report_dum_2009=1 if (acty==2009 & devl_period==1) | (acty==2010 & devl_period==2) | (acty==2011 & devl_period==3) 
gen report_dum_2010=0
replace report_dum_2010=1 if (acty==2010 & devl_period==1) | (acty==2011 & devl_period==2) 

capture dropvars report_counter
gen report_counter=0
replace report_counter=1 if report_dum_2008==1 
replace report_counter=2 if report_dum_2009==1 
replace report_counter=3 if report_dum_2010==1 

** Table 1
reg ln_dev_lall_absolute  l.ln_dev_lall_absolute l.ln_pop l.ln_gdppc l.polity2 fragmentation_1   i.acty report_dum_*  i.devl_period,  cluster(country)
outreg2 using table1, replace excel
reg ln_dev_lall_absolute  l.ln_dev_lall_absolute l.ln_pop l.ln_gdppc l.polity2  fragmentation_2    i.acty report_dum_*  i.devl_period,  cluster(country)
outreg2 using table1, append excel
reg ln_dev_lall_absolute  l.ln_dev_lall_absolute l.ln_pop l.ln_gdppc l.polity2 fragmentation_3   i.acty report_dum_*  i.devl_period,  cluster(country)
outreg2 using table1, append excel


** Table 2
reg ln_dev_lall_absolute  dev_lall_negative_dum#c.l.ln_dev_lall_absolute dev_lall_negative_dum#c.l.ln_pop dev_lall_negative_dum#c.l.ln_gdppc dev_lall_negative_dum#c.l.polity2 dev_lall_negative_dum#c.fragmentation_1   i.acty report_dum_*  i.devl_period,  cluster(country)
test 0.dev_lall_negative_dum#c.l.ln_dev_lall_absolute=1.dev_lall_negative_dum#c.l.ln_dev_lall_absolute
test 0.dev_lall_negative_dum#c.l.ln_pop=1.dev_lall_negative_dum#c.l.ln_pop
test 0.dev_lall_negative_dum#c.l.ln_gdppc=1.dev_lall_negative_dum#c.l.ln_gdppc
test 0.dev_lall_negative_dum#c.l.polity2=1.dev_lall_negative_dum#c.l.polity2
test 0.dev_lall_negative_dum#c.fragmentation_1=1.dev_lall_negative_dum#c.fragmentation_1
outreg2 using table2, replace excel
reg ln_dev_lall_absolute  dev_lall_negative_dum#c.l.ln_dev_lall_absolute dev_lall_negative_dum#c.l.ln_pop dev_lall_negative_dum#c.l.ln_gdppc dev_lall_negative_dum#c.l.polity2  dev_lall_negative_dum#c.fragmentation_2    i.acty report_dum_*  i.devl_period,  cluster(country)
test 0.dev_lall_negative_dum#c.l.ln_dev_lall_absolute=1.dev_lall_negative_dum#c.l.ln_dev_lall_absolute
test 0.dev_lall_negative_dum#c.l.ln_pop=1.dev_lall_negative_dum#c.l.ln_pop
test 0.dev_lall_negative_dum#c.l.ln_gdppc=1.dev_lall_negative_dum#c.l.ln_gdppc
test 0.dev_lall_negative_dum#c.l.polity2=1.dev_lall_negative_dum#c.l.polity2
test 0.dev_lall_negative_dum#c.fragmentation_2=1.dev_lall_negative_dum#c.fragmentation_2
outreg2 using table2, append excel
reg ln_dev_lall_absolute  dev_lall_negative_dum#c.l.ln_dev_lall_absolute dev_lall_negative_dum#c.l.ln_pop dev_lall_negative_dum#c.l.ln_gdppc dev_lall_negative_dum#c.l.polity2 dev_lall_negative_dum#c.fragmentation_3   i.acty report_dum_*  i.devl_period,  cluster(country)
test 0.dev_lall_negative_dum#c.l.ln_dev_lall_absolute=1.dev_lall_negative_dum#c.l.ln_dev_lall_absolute
test 0.dev_lall_negative_dum#c.l.ln_pop=1.dev_lall_negative_dum#c.l.ln_pop
test 0.dev_lall_negative_dum#c.l.ln_gdppc=1.dev_lall_negative_dum#c.l.ln_gdppc
test 0.dev_lall_negative_dum#c.l.polity2=1.dev_lall_negative_dum#c.l.polity2
test 0.dev_lall_negative_dum#c.fragmentation_3=1.dev_lall_negative_dum#c.fragmentation_3
outreg2 using table2, append excel

** Table 3
* Extension: add further variables of need and merit
reg ln_dev_lall_absolute  dev_lall_negative_dum#c.l.ln_dev_lall_absolute  dev_lall_negative_dum#c.l.ln_pop dev_lall_negative_dum#c.l.ln_gdppc dev_lall_negative_dum#c.l.polity2 dev_lall_negative_dum#c.fragmentation_3  dev_lall_negative_dum#c.l.d.polity2  dev_lall_negative_dum#c.l.diff_gr_rate dev_lall_negative_dum#c.l.ln_sumaffected dev_lall_negative_dum#c.orphan1lt1 dev_lall_negative_dum#c.darling1gt1   i.acty report_dum_*  i.devl_period,  cluster(country)
test 0.dev_lall_negative_dum#c.l.ln_dev_lall_absolute=1.dev_lall_negative_dum#c.l.ln_dev_lall_absolute
test 0.dev_lall_negative_dum#c.l.ln_pop=1.dev_lall_negative_dum#c.l.ln_pop
test 0.dev_lall_negative_dum#c.l.ln_gdppc=1.dev_lall_negative_dum#c.l.ln_gdppc
test 0.dev_lall_negative_dum#c.l.polity2=1.dev_lall_negative_dum#c.l.polity2
test 0.dev_lall_negative_dum#c.fragmentation_3=1.dev_lall_negative_dum#c.fragmentation_3
test 0.dev_lall_negative_dum#c.l.d.polity2=1.dev_lall_negative_dum#c.l.d.polity2
test 0.dev_lall_negative_dum#c.l.diff_gr_rate=1.dev_lall_negative_dum#c.l.diff_gr_rate
test 0.dev_lall_negative_dum#c.l.ln_sumaffected=1.dev_lall_negative_dum#c.l.ln_sumaffected
test 0.dev_lall_negative_dum#c.orphan1lt1=1.dev_lall_negative_dum#c.orphan1lt1
test 0.dev_lall_negative_dum#c.darling1gt1=1.dev_lall_negative_dum#c.darling1gt1
outreg2 using table3, replace excel

* Extension: add donor characteristics
reg ln_dev_lall_absolute  dev_lall_negative_dum#c.l.ln_dev_lall_absolute  dev_lall_negative_dum#c.l.ln_pop dev_lall_negative_dum#c.l.ln_gdppc dev_lall_negative_dum#c.l.polity2 dev_lall_negative_dum#c.fragmentation_3  dev_lall_negative_dum#c.sh_not_spplan  dev_lall_negative_dum#c.sh_egoistic   i.acty report_dum_*  i.devl_period,  cluster(country)
test 0.dev_lall_negative_dum#c.l.ln_dev_lall_absolute=1.dev_lall_negative_dum#c.l.ln_dev_lall_absolute
test 0.dev_lall_negative_dum#c.l.ln_pop=1.dev_lall_negative_dum#c.l.ln_pop
test 0.dev_lall_negative_dum#c.l.ln_gdppc=1.dev_lall_negative_dum#c.l.ln_gdppc
test 0.dev_lall_negative_dum#c.l.polity2=1.dev_lall_negative_dum#c.l.polity2
test 0.dev_lall_negative_dum#c.fragmentation_3=1.dev_lall_negative_dum#c.fragmentation_3
test 0.dev_lall_negative_dum#c.sh_not_spplan=1.dev_lall_negative_dum#c.sh_not_spplan
test 0.dev_lall_negative_dum#c.sh_egoistic=1.dev_lall_negative_dum#c.sh_egoistic
outreg2 using table3, append excel

* Extension: add specific donor motives
reg ln_dev_lall_absolute  dev_lall_negative_dum#c.l.ln_dev_lall_absolute  dev_lall_negative_dum#c.l.ln_pop dev_lall_negative_dum#c.l.ln_gdppc dev_lall_negative_dum#c.l.polity2 dev_lall_negative_dum#c.fragmentation_3  dev_lall_negative_dum#c.l.unsc  dev_lall_negative_dum#c.l.ratios dev_lall_negative_dum#c.l.durchschnitt i.acty report_dum_*  i.devl_period,  cluster(country)
test 0.dev_lall_negative_dum#c.l.ln_dev_lall_absolute=1.dev_lall_negative_dum#c.l.ln_dev_lall_absolute
test 0.dev_lall_negative_dum#c.l.ln_pop=1.dev_lall_negative_dum#c.l.ln_pop
test 0.dev_lall_negative_dum#c.l.ln_gdppc=1.dev_lall_negative_dum#c.l.ln_gdppc
test 0.dev_lall_negative_dum#c.l.polity2=1.dev_lall_negative_dum#c.l.polity2
test 0.dev_lall_negative_dum#c.fragmentation_3=1.dev_lall_negative_dum#c.fragmentation_3
test 0.dev_lall_negative_dum#c.l.unsc=1.dev_lall_negative_dum#c.l.unsc
test 0.dev_lall_negative_dum#c.l.ratios=1.dev_lall_negative_dum#c.l.ratios
test 0.dev_lall_negative_dum#c.l.durchschnitt=1.dev_lall_negative_dum#c.l.durchschnitt
outreg2 using table3, append excel

* Extension: add all additional control variables
reg ln_dev_lall_absolute  dev_lall_negative_dum#c.l.ln_dev_lall_absolute  dev_lall_negative_dum#c.l.ln_pop dev_lall_negative_dum#c.l.ln_gdppc dev_lall_negative_dum#c.l.polity2  dev_lall_negative_dum#c.fragmentation_3  dev_lall_negative_dum#c.l.d.polity2 dev_lall_negative_dum#c.l.diff_gr_rate dev_lall_negative_dum#c.l.ln_sumaffected dev_lall_negative_dum#c.orphan1lt1 dev_lall_negative_dum#c.darling1gt1    dev_lall_negative_dum#c.sh_not_spplan  dev_lall_negative_dum#c.sh_egoistic  dev_lall_negative_dum#c.l.unsc  dev_lall_negative_dum#c.l.ratios dev_lall_negative_dum#c.l.durchschnitt i.acty report_dum_*  i.devl_period,  cluster(country)
test 0.dev_lall_negative_dum#c.l.ln_dev_lall_absolute=1.dev_lall_negative_dum#c.l.ln_dev_lall_absolute
test 0.dev_lall_negative_dum#c.l.ln_pop=1.dev_lall_negative_dum#c.l.ln_pop
test 0.dev_lall_negative_dum#c.l.ln_gdppc=1.dev_lall_negative_dum#c.l.ln_gdppc
test 0.dev_lall_negative_dum#c.l.polity2=1.dev_lall_negative_dum#c.l.polity2
test 0.dev_lall_negative_dum#c.fragmentation_3=1.dev_lall_negative_dum#c.fragmentation_3
test 0.dev_lall_negative_dum#c.l.d.polity2=1.dev_lall_negative_dum#c.l.d.polity2
test 0.dev_lall_negative_dum#c.l.diff_gr_rate=1.dev_lall_negative_dum#c.l.diff_gr_rate
test 0.dev_lall_negative_dum#c.l.ln_sumaffected=1.dev_lall_negative_dum#c.l.ln_sumaffected
test 0.dev_lall_negative_dum#c.orphan1lt1=1.dev_lall_negative_dum#c.orphan1lt1
test 0.dev_lall_negative_dum#c.darling1gt1=1.dev_lall_negative_dum#c.darling1gt1
test 0.dev_lall_negative_dum#c.sh_not_spplan=1.dev_lall_negative_dum#c.sh_not_spplan
test 0.dev_lall_negative_dum#c.sh_egoistic=1.dev_lall_negative_dum#c.sh_egoistic
test 0.dev_lall_negative_dum#c.l.unsc=1.dev_lall_negative_dum#c.l.unsc
test 0.dev_lall_negative_dum#c.l.ratios=1.dev_lall_negative_dum#c.l.ratios
test 0.dev_lall_negative_dum#c.l.durchschnitt=1.dev_lall_negative_dum#c.l.durchschnitt
outreg2 using table3, append excel




** Table 4
* Two-way clustering
cgmreg ln_dev_lall_absolute  dev_lall_negative_dum#c.l.ln_dev_lall_absolute dev_lall_negative_dum#c.l.ln_pop dev_lall_negative_dum#c.l.ln_gdppc dev_lall_negative_dum#c.l.polity2 dev_lall_negative_dum#c.fragmentation_3  i.acty report_dum_*  i.devl_period,  cluster(country report_counter)
test 0.dev_lall_negative_dum#c.l.ln_dev_lall_absolute=1.dev_lall_negative_dum#c.l.ln_dev_lall_absolute
test 0.dev_lall_negative_dum#c.l.ln_pop=1.dev_lall_negative_dum#c.l.ln_pop
test 0.dev_lall_negative_dum#c.l.ln_gdppc=1.dev_lall_negative_dum#c.l.ln_gdppc
test 0.dev_lall_negative_dum#c.l.polity2=1.dev_lall_negative_dum#c.l.polity2
test 0.dev_lall_negative_dum#c.fragmentation_3=1.dev_lall_negative_dum#c.fragmentation_3
outreg2 using table4, replace excel

* Robustness test: insert regional dummy variables
reg ln_dev_lall_absolute  dev_lall_negative_dum#c.l.ln_dev_lall_absolute dev_lall_negative_dum#c.l.ln_pop dev_lall_negative_dum#c.l.ln_gdppc dev_lall_negative_dum#c.l.polity2 dev_lall_negative_dum#c.fragmentation_3  reg_* i.acty report_dum_*  i.devl_period,  cluster(country)
test 0.dev_lall_negative_dum#c.l.ln_dev_lall_absolute=1.dev_lall_negative_dum#c.l.ln_dev_lall_absolute
test 0.dev_lall_negative_dum#c.l.ln_pop=1.dev_lall_negative_dum#c.l.ln_pop
test 0.dev_lall_negative_dum#c.l.ln_gdppc=1.dev_lall_negative_dum#c.l.ln_gdppc
test 0.dev_lall_negative_dum#c.l.polity2=1.dev_lall_negative_dum#c.l.polity2
test 0.dev_lall_negative_dum#c.fragmentation_3=1.dev_lall_negative_dum#c.fragmentation_3
outreg2 using table4, append excel



* Robustness test: not stacked
use "Article for ID (aid) non-stacked.dta", replace
tsset country_id acty

reg ln_devl1_absolute  devl1_negative_dum#c.l.ln_devl1_absolute devl1_negative_dum#c.l.ln_pop devl1_negative_dum#c.l.ln_gdppc devl1_negative_dum#c.l.polity2 devl1_negative_dum#c.fragmentation_3   i.acty  ,  cluster(country)
test 0.devl1_negative_dum#c.l.ln_devl1_absolute=1.devl1_negative_dum#c.l.ln_devl1_absolute
test 0.devl1_negative_dum#c.l.ln_pop=1.devl1_negative_dum#c.l.ln_pop
test 0.devl1_negative_dum#c.l.ln_gdppc=1.devl1_negative_dum#c.l.ln_gdppc
test 0.devl1_negative_dum#c.l.polity2=1.devl1_negative_dum#c.l.polity2
test 0.devl1_negative_dum#c.fragmentation_3=1.devl1_negative_dum#c.fragmentation_3
outreg2 using table4, append excel
su ln_devl1_absolute if e(sample)
reg ln_devl2_absolute  devl2_negative_dum#c.l.ln_devl2_absolute devl2_negative_dum#c.l.ln_pop devl2_negative_dum#c.l.ln_gdppc devl2_negative_dum#c.l.polity2 devl2_negative_dum#c.fragmentation_3   i.acty ,  cluster(country)
test 0.devl2_negative_dum#c.l.ln_devl2_absolute=1.devl2_negative_dum#c.l.ln_devl2_absolute
test 0.devl2_negative_dum#c.l.ln_pop=1.devl2_negative_dum#c.l.ln_pop
test 0.devl2_negative_dum#c.l.ln_gdppc=1.devl2_negative_dum#c.l.ln_gdppc
test 0.devl2_negative_dum#c.l.polity2=1.devl2_negative_dum#c.l.polity2
test 0.devl2_negative_dum#c.fragmentation_3=1.devl2_negative_dum#c.fragmentation_3
outreg2 using table4, append excel
su ln_devl2_absolute if e(sample)
reg ln_devl3_absolute  devl3_negative_dum#c.l.ln_devl3_absolute devl3_negative_dum#c.l.ln_pop devl3_negative_dum#c.l.ln_gdppc devl3_negative_dum#c.l.polity2 devl3_negative_dum#c.fragmentation_3   i.acty ,  cluster(country)
test 0.devl3_negative_dum#c.l.ln_devl3_absolute=1.devl3_negative_dum#c.l.ln_devl3_absolute
test 0.devl3_negative_dum#c.l.ln_pop=1.devl3_negative_dum#c.l.ln_pop
test 0.devl3_negative_dum#c.l.ln_gdppc=1.devl3_negative_dum#c.l.ln_gdppc
test 0.devl3_negative_dum#c.l.polity2=1.devl3_negative_dum#c.l.polity2
test 0.devl3_negative_dum#c.fragmentation_3=1.devl3_negative_dum#c.fragmentation_3
outreg2 using table4, append excel
su ln_devl3_absolute if e(sample)


* Appendix 2
use "Article for ID (aid) stacked.dta", replace
tsset country_id_devl_period acty

quietly reg ln_dev_lall_absolute  dev_lall_negative_dum#c.l.ln_dev_lall_absolute dev_lall_negative_dum#c.l.ln_pop dev_lall_negative_dum#c.l.ln_gdppc dev_lall_negative_dum#c.l.polity2 dev_lall_negative_dum#c.fragmentation_1   i.acty report_dum_*  i.devl_period,  cluster(country)
su ln_dev_lall_absolute  l.ln_dev_lall_absolute  l.ln_pop l.ln_gdppc l.polity2  fragmentation_1 fragmentation_2 fragmentation_3  l.d.polity2 l.diff_gr_rate l.ln_sumaffected orphan1lt1 darling1gt1    sh_not_spplan  sh_egoistic  l.unsc  l.ratios l.durchschnitt active_donors if e(sample)

